package string;

public class SubstringDemo {
    public static void main(String[] args) {
        String s = "www.baidu.com.cn";
        int first = s.indexOf(".")+1;
        //int last = s.lastIndexOf(".");
        int last = s.indexOf(".",first+1);
        System.out.println(s.substring(first, last));
    }
}
